import Router from 'koa-router';
const router = new Router();
import proxyService from '../../common/proxyService';
import {
  getCorpListMultiByPagerAgent,
  getOrderListByPageForAgent,
  getCorpPackageInfoAgent,
  getCorpInfoMultiAgent,
  getDetailAgent,
  getKfFunctionByConditionAgent,
} from '../../api/agent';

router.get('/getCorpListMultiByPagerAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, getCorpListMultiByPagerAgent);
  return (ctx.body = response);
});
router.get('/getKfFunctionByConditionAgent', async ctx => {
  const functionTypes = ctx.requestParams['functionTypes[]'];
  if (typeof functionTypes === 'string') {
    ctx.requestParams['functionTypes'] = [functionTypes];
  } else {
    ctx.requestParams['functionTypes'] = functionTypes;
  }
  delete ctx.requestParams['functionTypes[]'];
  const response = await proxyService.postProxy(ctx, getKfFunctionByConditionAgent);
  return (ctx.body = response);
});
router.get('/getDetailAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, getDetailAgent);
  return (ctx.body = response);
});
router.get('/getOrderListByPageForAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, getOrderListByPageForAgent);
  return (ctx.body = response);
});
router.get('/getCorpPackageInfoAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, getCorpPackageInfoAgent);
  return (ctx.body = response);
});
router.get('/getCorpInfoMultiAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, getCorpInfoMultiAgent);
  return (ctx.body = response);
});
module.exports = router;
